<template>
  <div class="public-device-container">
    <!-- 顶部标题栏 -->
    <TopHeader />

    <div class="public-device-content">
      <router-view />
    </div>

    <!-- 底部操作栏 -->
    <Bottom />
  </div>
</template>

<script setup>
import TopHeader from '@/components/public/TopHeader.vue'
import Bottom from '@/components/public/Bottom.vue'
import { ref, onMounted, onUnmounted, computed } from 'vue'
import { 
  Monitor, 
  Microphone, 
  Headset, 
  ArrowLeft, 
  QuestionFilled, 
  SwitchButton,
  User,
  Document,
  Coin,
  Printer,
  Ticket,
  List
} from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'

// 当前时间显示
const currentTime = ref('')
let timeInterval = null

onMounted(() => {
  updateTime()
  timeInterval = setInterval(updateTime, 1000)
})

onUnmounted(() => {
  if (timeInterval) clearInterval(timeInterval)
})

const updateTime = () => {
  const now = new Date()
  currentTime.value = now.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit',
    weekday: 'short'
  })
}

// 自助挂号缴费机选项
const selfServiceOptions = ref([
  { id: 1, title: '自助挂号', desc: '选择科室与医生进行挂号', icon: Ticket, disabled: false },
  { id: 2, title: '门诊缴费', desc: '使用医保卡或扫码支付', icon: Coin, disabled: false },
  { id: 3, title: '报告打印', desc: '打印检验检查报告单', icon: Printer, disabled: true },
  { id: 4, title: '信息查询', desc: '查询就诊记录与费用', icon: Document, disabled: false },
  { id: 5, title: '医保服务', desc: '医保相关业务办理', icon: List, disabled: true },
  { id: 6, title: '病历打印', desc: '打印门诊病历与处方', icon: Printer, disabled: false }
])

// 选择自助服务
const selectSelfService = (option) => {
  ElMessage.info(`您选择了: ${option.title}`)
  // 实际应用中这里会跳转到相应页面或打开对应功能
}

// 门诊叫号系统数据
const selectedDepartment = ref(1)

const departments = ref([
  { id: 1, name: '内科' },
  { id: 2, name: '外科' },
  { id: 3, name: '儿科' },
  { id: 4, name: '妇产科' },
  { id: 5, name: '眼科' },
  { id: 6, name: '耳鼻喉科' }
])

// 模拟当前叫号信息
const currentCall = ref({
  patient: {
    number: 'A015',
    name: '张*明'
  },
  room: '内科诊室3'
})

// 模拟等候队列
const waitingPatients = ref([
  { number: 'A016', name: '李*华', status: '等候中' },
  { number: 'A017', name: '王*芳', status: '等候中' },
  { number: 'A018', name: '赵*伟', status: '等候中' },
  { number: 'A019', name: '刘*婷', status: '预约等候' },
  { number: 'A020', name: '陈*强', status: '预约等候' }
])

// 底部操作按钮功能
const goBack = () => {
  ElMessage.info('返回上级页面')
}

const showHelp = () => {
  ElMessage.info('显示使用帮助')
}

const switchLanguage = () => {
  ElMessage.info('切换系统语言')
}
</script>

<style lang="scss" scoped>
.public-device-container {
  height: 100vh;
  background: #f5f7fa;
  display: flex;
  flex-direction: column;
}



// 主要内容区域
.public-device-content {
  flex: 1;
  display: grid;
  //grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 20px;
  overflow: auto;
}

.device-section {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.section-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #ebeef5;
  
  h2 {
    margin: 0 0 0 10px;
    font-size: 18px;
    color: #303133;
  }
  
  .el-icon {
    font-size: 24px;
    color: #1a75bc;
  }
}

// 自助服务选项样式
.device-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  flex: 1;
}

.option-card {
  border: 1px solid #ebeef5;
  border-radius: 6px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  
  &:hover:not(.disabled) {
    border-color: #1a75bc;
    box-shadow: 0 2px 12px 0 rgba(26, 117, 188, 0.2);
    transform: translateY(-2px);
  }
  
  &.disabled {
    cursor: not-allowed;
    opacity: 0.6;
  }
}

.option-icon {
  font-size: 32px;
  color: #1a75bc;
  margin-bottom: 10px;
}

.option-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 5px;
  color: #303133;
}

.option-desc {
  font-size: 12px;
  color: #909399;
}

.status-tag {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #f56c6c;
  color: white;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 10px;
}

// 叫号系统样式
.queue-system {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.department-selector {
  margin-bottom: 20px;
  
  :deep(.el-radio-group) {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
  
  :deep(.el-radio-button) {
    flex: 1;
    min-width: 80px;
    
    .el-radio-button__inner {
      width: 100%;
    }
  }
}

.current-call {
  background: linear-gradient(135deg, #1a75bc 0%, #0c4d8c 100%);
  color: white;
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 20px;
  text-align: center;
}

.call-header {
  font-size: 16px;
  margin-bottom: 15px;
  opacity: 0.9;
}

.call-info {
  .patient-number {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 5px;
  }
  
  .patient-name {
    font-size: 18px;
    margin-bottom: 10px;
  }
  
  .room-info {
    font-size: 14px;
    opacity: 0.8;
  }
}

.no-call {
  font-size: 16px;
  padding: 20px 0;
}

.waiting-queue {
  flex: 1;
  border: 1px solid #ebeef5;
  border-radius: 6px;
  overflow: hidden;
}

.queue-header {
  background: #f5f7fa;
  padding: 10px 15px;
  font-weight: 600;
  border-bottom: 1px solid #ebeef5;
}

.queue-list {
  max-height: 250px;
  overflow-y: auto;
}

.queue-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 15px;
  border-bottom: 1px solid #ebeef5;
  
  &:last-child {
    border-bottom: none;
  }
  
  &:nth-child(odd) {
    background: #fafafa;
  }
}

.queue-number {
  font-weight: 600;
  color: #1a75bc;
}

.queue-name {
  flex: 1;
  margin-left: 15px;
}

.queue-status {
  color: #67c23a;
  font-size: 12px;
}


// 响应式设计
@media (max-width: 992px) {
  .public-device-content {
    grid-template-columns: 1fr;
  }
  
  .device-options {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .device-options {
    grid-template-columns: 1fr;
  }
  
  .department-selector {
    :deep(.el-radio-group) {
      flex-direction: column;
    }
  }
  
  .top-header {
    padding: 0 15px;
    
    .page-title {
      font-size: 18px;
    }
  }
}
</style>